/*
 * <p>Copyright® 2009-2022 东软 IT 实训中心版权所有。</p>
 */

package com.max.back.doctor.api;

import com.github.pagehelper.PageInfo;
import com.max.back.common.http.ResponseResult;
import com.max.back.doctor.form.RegistrationPatientBaseInfoPageForm;
import com.max.back.doctor.service.RegistrationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotBlank;
import java.util.List;
import java.util.Map;

/**
* @description 
* 
* <p>
* <code>RegistrationApi</code>
*
* </p>
* @see 
* @author 辛凤文 forward.seen@foxmail.com
* @version 1.0 
* @time 2022/7/20 14:48 
*/
@CrossOrigin
@Validated
@RestController
@RequestMapping("/registrationApi")
public class RegistrationApi {

    @Autowired
    private RegistrationService registrationService;

    @GetMapping("/getRegisterListForDoctor")
    public ResponseResult<List<Map<String,Object>>> getRegisterListForDoctor(@NotBlank String doctorId){
        return ResponseResult.getSuccessResult(registrationService.registrationPatientBaseInfo(doctorId));
    }

    @GetMapping("/getTotalRegistration")
    public ResponseResult<Integer> getTotalRegistrationForDoctor(@NotBlank String doctorId){
        return ResponseResult.getSuccessResult(registrationService.getRegistrationCountByDoctor(doctorId));
    }

    @PostMapping("/getRegisterPageForDoctor")
    public ResponseResult<PageInfo<Map<String, Object>>> getTotalRegistrationForDoctor(@Validated @RequestBody RegistrationPatientBaseInfoPageForm pageForm){
        PageInfo<Map<String, Object>> pageInfo = registrationService.registrationPatientBaseInfoPage(pageForm.getDoctorId(), pageForm.getPageNum(), pageForm.getPageSize());
        return ResponseResult.getSuccessResult(pageInfo);
    }
}